#ifndef VENUS_EFFECTS_FRESNEL_EFFECT_H
#define VENUS_EFFECTS_FRESNEL_EFFECT_H

#include "effect.h"
#include "graphics/error_gl.h"

namespace venus {
class Point;
class FresnelEffect : public Effect {
 public:
  FresnelEffect(float eta_ratio, float fresnel_bias, float fresnel_scale,
                float fresnel_power);
  virtual void Begin() const;
  virtual void End() const;
  void set_env_map(int env_map) { env_map_ = env_map; }
  void set_eye_pos(const Point *eye_pos) { eye_pos_ = eye_pos; }
  /*void set_material_color(const Color *material_color) {
    material_color_ = material_color;
  }*/

  float eta_ratio() const { return eta_ratio_; }
  float fresnel_bias() const { return fresnel_bias_; }
  float fresnel_scale() const { return fresnel_scale_; }
  float fresnel_power() const { return fresnel_power_; }

  void set_eta_ratio(float eta_ratio) { 
    eta_ratio_ = eta_ratio;
    Info("eta ratio: %f", eta_ratio_);
  }
  void set_fresnel_bias(float fresnel_bias) { 
    fresnel_bias_ = fresnel_bias;
    Info("fresnel bias: %f", fresnel_bias_);
  }
  void set_fresnel_scale(float fresnel_scale) { 
    fresnel_scale_ = fresnel_scale; 
    Info("fresnel scale: %f", fresnel_scale_);
  }
  void set_fresnel_power(float fresnel_power) {
    fresnel_power_ = fresnel_power;
    Info("fresnel power: %f", fresnel_power_);
  }
 private:
  //!!! the following three may be encapsulated in a data structure
  //that descript the scene
  const Point *eye_pos_;
  //const Color *material_color_;
  int env_map_;

  //Fresnel parameters
  float eta_ratio_;
  float fresnel_bias_;
  float fresnel_scale_;
  float fresnel_power_;

  //shader uniform handles
  GLint eye_pos_var_;
  //GLint material_color_var_;
  GLint env_map_var_;
  GLint eta_ratio_var_;
  GLint fresnel_bias_var_;
  GLint fresnel_scale_var_;
  GLint fresnel_power_var_;
};
} // namespace venus

#endif // VENUS_EFFECTS_FRESNEL_EFFECT_H
